export default {
  namespaced: true,
  state: {
    //是否显示提示框
    isShowToast: false,
    //提示信息
    toastMsg: "",
    //提示类型(控制图标)  success warning danger
    toastType: "",
  },
  getters: {},
  mutations: {
    //修改toast
    changeIsShowToast(state, payload) {
      state.isShowToast = payload.isShowToast;
      if (payload.isShowToast) {
        state.toastMsg = payload.toastMsg;
        state.toastType = payload.toastType;
      }
    },
  },
  actions: {
    //异步修改提示框信息
    asyncChangeIsShowToast({ commit }, payload) {
      commit("changeIsShowToast", {
        isShowToast: true,
        toastMsg: payload.toastMsg,
        toastType: payload.toastType,
      });
      //定时器方式关闭
      setTimeout(() => {
        commit("changeIsShowToast", {
          isShowToast: false,
        });
      }, 1000);
    },
  },
};
